package com.link.serve.tcp.process.factory;


import com.link.serve.tcp.process.AbstractMessageProcessor;
import com.link.serve.tcp.process.HeartbeatProcessor;
import com.link.serve.tcp.process.LoginProcessor;
import com.link.serve.tcp.process.SingleMessagePushProcessor;
import com.link.serve.type.IMCmdType;
import com.link.serve.utils.SpringContextHolder;

/**
 *
 */
public class ProcessorFactory {

    public static AbstractMessageProcessor createProcessor(IMCmdType cmd) {
        AbstractMessageProcessor processor = null;
        switch (cmd) {
            case LOGIN:
                processor = SpringContextHolder.getApplicationContext().getBean(LoginProcessor.class);
                break;
            case PRIVATE_MESSAGE:
                processor = SpringContextHolder.getApplicationContext().getBean(SingleMessagePushProcessor.class);
                break;
            case HEART_BEAT:
                processor = SpringContextHolder.getApplicationContext().getBean(HeartbeatProcessor.class);
                break;
            default:
                break;
        }
        return processor;
    }

}
